home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / forth / pfe-0.000 / pfe-0 / pfe-0.9.13 / src / virtual.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-17  |  4.1 KB  |  178 lines

  1. /*
  2.  * This file is part of the portable Forth environment written in ANSI C.
  3.  * Copyright (C) 1995  Dirk Uwe Zoller
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13.  * See the GNU Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public
  16.  * License along with this library; if not, write to the Free
  17.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * This file is version 0.9.13 of 17-July-95
  20.  * Check for the latest version of this package via anonymous ftp at
  21.  *    roxi.rz.fht-mannheim.de:/pub/languages/forth/pfe-VERSION.tar.gz
  22.  * or    sunsite.unc.edu:/pub/languages/forth/pfe-VERSION.tar.gz
  23.  * or    ftp.cygnus.com:/pub/forth/pfe-VERSION.tar.gz
  24.  *
  25.  * Please direct any comments via internet to
  26.  *    duz@roxi.rz.fht-mannheim.de.
  27.  * Thank You.
  28.  */
  29. /*
  30.  * virtual.h ---    Declares types and variables of the virtual machine.
  31.  * (duz 09Oct94)
  32.  */
  33.  
  34. /* *INDENT-OFF* */
  35.  
  36. #ifndef __VIRTUAL_H
  37. #define __VIRTUAL_H
  38.  
  39. /* First the register assignments if GNU-C is used. ======================== */
  40.  
  41. #if !defined __GNUC__ || defined  __STRICT_ANSI__ || defined __cplusplus
  42. # undef USE_REGS
  43. #endif
  44.  
  45. #ifdef USE_REGS
  46. # if defined AIX1
  47.  
  48. #   define REGIP "%ebx"
  49.  
  50. # elif defined Linux || defined FreeBSD || defined EMX || defined NeXTstep
  51.  
  52. #   define REGIP "%ebx"
  53. #   define REGSP "%ebp"
  54.  
  55. # elif defined AIX3
  56.  
  57. #   define REGIP "13"
  58. #   define REGSP "14"
  59. #   define REGRP "15"
  60. #   define REGW  "16"
  61. #   define REGLP "17"
  62. #   define REGFP "18"
  63.  
  64. # elif defined HPUX68K
  65.  
  66. #   define REGIP "%a3"
  67. #   define REGSP "%a4"
  68. #   define REGRP "%a5"
  69. #   define REGW  "%d4"
  70. #   define REGLP "%d5"
  71.  
  72. # elif defined HPUXRISC
  73.  
  74. #   define REGIP "%r13"
  75. #   define REGSP "%r14"
  76. #   define REGRP "%r15"
  77. #   define REGW  "%r16"
  78. #   define REGLP "%r17"
  79. #   define REGFP "%r18"
  80.  
  81. # elif defined ULTRIX
  82.  
  83. #   define REGIP "$18"
  84. #   define REGSP "$19"
  85. #   define REGRP "$20"
  86. #   define REGW  "$21"
  87. #   define REGLP "$22"
  88. #   define REGFP "$23"
  89.  
  90. # elif defined OSF1
  91.  
  92. #   define REGIP "$10"
  93. #   define REGSP "$11"
  94. #   define REGRP "$12"
  95. #   define REGW  "$13"
  96. #   define REGLP "$14"
  97. #   define REGFP "$15"
  98.  
  99. # else
  100.  
  101. #   undef USE_REGS
  102.  
  103. # endif
  104. #endif
  105.  
  106.  
  107. /* The basic types: ======================================================== */
  108.  
  109. typedef CELL_TYPE        Cell;    /* a stack item */
  110. typedef unsigned CELL_TYPE    uCell;    /* dito unsigned */
  111. typedef struct
  112.     { Cell hi; uCell lo; }    dCell;    /* dito, double precision signed */
  113. typedef struct
  114.     { uCell hi, lo; }    udCell;    /* dito, double precision unsigned */
  115.  
  116. typedef unsigned HALF_CELL_TYPE    hCell;    /* a smaller unsigned number */
  117.  
  118. typedef void (*pCode) (void);        /* pointer to executable code */
  119. typedef pCode *Xt;            /* type of the "execution token" */
  120.  
  121. typedef struct { Cell    quot, rem; } fdiv_t;
  122. typedef struct { uCell    quot, rem; } udiv_t;
  123.  
  124. typedef struct                /* "map" of a Cell */
  125. {
  126. #if HIGHBYTE_FIRST
  127.   hCell    hi, lo;
  128. #else
  129.   hCell    lo, hi;
  130. #endif
  131. } Cell_map;
  132.  
  133.  
  134. /* Virtual machine registers, declared as variables: ======================= */
  135.  
  136. #ifdef REGIP            /* the instruction pointer */
  137. register Xt *    ip asm (REGIP);
  138. #else
  139. extern Xt *    ip;
  140. #endif
  141.  
  142. #ifdef REGW            /* used inside the inner interpreter */
  143. register Xt    W asm (REGW);
  144. #else
  145. # ifdef REGIP
  146. #   define W    (ip [-1])
  147. # else
  148. extern Xt    W;
  149. # endif
  150. #endif
  151.  
  152. #ifdef REGSP            /* the stack pointer */
  153. register Cell *    sp asm (REGSP);
  154. #else
  155. extern Cell *    sp;
  156. #endif
  157.  
  158. #ifdef REGRP            /* the return stack pointer */
  159. register Xt **    rp asm (REGRP);
  160. #else
  161. extern Xt **    rp;
  162. #endif
  163.  
  164. #ifdef REGLP            /* pointer to local variables */
  165. register Cell *    lp asm (REGLP);
  166. #else
  167. extern Cell *    lp;
  168. #endif
  169.  
  170. #ifdef REGFP            /* the floating point stack pointer */
  171. register double *fp asm (REGFP);
  172. #else
  173. extern double *    fp;
  174. #endif
  175.  
  176.  
  177. #endif /* ndef __VIRTUAL_H */
  178.